using Agron.Data.Contracts;
using Agron.Services.Contracts;

using System;
using System.Collections.Generic;
using System.ServiceModel;


namespace Agron.Services.Proxies
{
    /// <summary>
    /// Provides a <see cref="ClientBase{ISchedulerService}"/> implementation for the <see cref="ISchedulerService"/> service contract.
    /// </summary>
    public class SchedulerServiceProxy : ClientBase<ISchedulerService>, ISchedulerService
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="SchedulerServiceProxy"/> class.
        /// </summary>
        public SchedulerServiceProxy() { }

        /// <summary>
        /// Creates a new session record in the data store.
        /// </summary>
        /// <param name="session">The <see cref="Session"/> data contract that will be created in the data store.</param>
        /// <exception cref="ArgumentNullException"><paramref name="session"/> is null.</exception>
        public void CreateSession(Session session)
        {
            if (null == session)
                throw new ArgumentNullException("session");

            base.Channel.CreateSession(session);
        }

        /// <summary>
        /// Deletes the specified session.
        /// </summary>
        /// <param name="sessionId">An <see cref="Int32"/> that uniquely specifies the session within the data store.</param>
        public void DeleteSession(int sessionId)
        {
            base.Channel.DeleteSession(sessionId);
        }

        /// <summary>
        /// Updates an existing session in the data store.
        /// </summary>
        /// <param name="session">The <see cref="Session"/> data contract that will be updated in the data store.</param>
        /// <exception cref="ArgumentNullException"><paramref name="session"/> is null.</exception>
        public void UpdateSession(Session session)
        {
            if (null == session)
                throw new ArgumentNullException("session");

            base.Channel.UpdateSession(session);
        }

        /// <summary>
        /// Gets a <see cref="IEnumerable{Session}"/> collection of session objects owned by a specified user within a particular range.
        /// </summary>
        /// <param name="userId">A <see cref="Guid"/> that uniquely identifies the user within the datastore.</param>
        /// <param name="min">A <see cref="DateTime"/> value that specifies the minimum part of the date range.</param>
        /// <param name="max">A <see cref="DateTime"/> value that specifies the maximum part of the date range.</param>
        /// <returns>
        /// A <see cref="IEnumerable{Session}"/> collection of session objects owned by a specified user within a particular range.
        /// </returns>
        public IEnumerable<Session> GetRange(Guid userId, DateTime min, DateTime max)
        {
            return base.Channel.GetRange(userId, min, max);
        }

        /// <summary>
        /// Gets a <see cref="Session"/> obeject from the datastore.
        /// </summary>
        /// <param name="sessionId">An <see cref="Int32"/> that uniquely specifies the session within the data store.</param>
        /// <returns>
        /// A <see cref="Session"/> obeject from the datastore or <c>null</c> if the session ID is invalid.
        /// </returns>
        public Session GetSessionInfo(int sessionId)
        {
            return base.Channel.GetSessionInfo(sessionId);
        }
    }
}